/*
 * DxfLAYER.java
 *
 * Created on 5 de Dezembro de 2007, 14:58
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package importadorDXF;

/**
 *
 * @author rafaelbuck
 */
public class DxfLAYER extends DxfTable
{
    
    /** Creates a new instance of DxfLAYER */
    DxfLAYER()
    {
        color = -1;
        visible = true;
        is0 = false;
    }

    /** Creates a new instance of DxfLAYER */
    DxfLAYER(String name)
    {
        color = -1;
        visible = true;
        is0 = false;
        super.name = name.toUpperCase();
        color = 7;
    }

    public boolean setGroup(short grpNr, short col)
    {
        if(grpNr == 62)
        {
            if(col < 0)
            {
                color = (short)(-col);
                super.flags |= 0x4000;
            } else
            {
                color = col;
                super.flags &= 0xbfff;
            }
            return true;
        } else
        {
            return super.setGroup(grpNr, color);
        }
    }

    public boolean setGroup(short grpNr, String str)
    {
        if(grpNr == 6)
        {
            linetype = str;
            return true;
        } else
        {
            return super.setGroup(grpNr, str);
        }
    }

    public boolean finishRead(DxfFile file)
    {
        visible = (super.flags & 0x4001) == 0;
        is0 = "0".equals(super.name);
        return true;
    }

    public boolean getVisibility()
    {
        return visible;
    }

    public void setVisibility(boolean onoff)
    {
        visible = onoff;
    }

    public boolean isLayer0()
    {
        return is0;
    }

    public short getColor()
    {
        setReferenced();
        return color;
    }

    public String getLineTypeName()
    {
        return linetype != null ? linetype : "CONTINUOUS";
    }

    public static final String DEFAUT_LAYER = "0";
    public static final short LAYER_FROZEN = 1;
    public static final short LAYER_AUTO_FROZEN = 2;
    public static final short LAYER_LOCKED = 4;
    public static final short LAYER_XREF = 8;
    public static final short LAYER_XREF_FOUND = 16;
    public static final short LAYER_USED = 32;
    public static final short LAYER_INVISIBLE = 16384;
    protected short color;
    protected String linetype;
    protected boolean visible;
    protected boolean is0;
}